<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>灯泡开关03</title>
    <style>
        .box{
            margin: 10px auto;
            text-align: center;
        }
        button{
            margin-bottom: 20px;
            outline: none;
            cursor: pointer;
            color: #fff;
            border-radius: 10%;
        }
    </style>
</head>
<body>
    <div class="box">
        <button type="button">开启</button><br/>
        <img src="img/pic_bulboff.gif" alt="">
        <!-- <img src="img/pic_bulbon.gif" alt=""> -->
    </div>
</body>
    <script>
        var btn = document.querySelector('button');
        var imgs = document.querySelector('img');
        btn.onclick = function(){
            if(btn.innerHTML == '开启'){
                imgs.src = 'img/pic_bulbon.gif'
                btn.innerHTML = '关闭';
                btn.style.background = '#3d156e'
            }else{
                imgs.src = 'img/pic_bulboff.gif'
                btn.innerHTML = '开启';
                btn.style.background = '#e5eb35'
            }
        }
    </script>
</html>